package com.meituan.stock.infra.model;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 删除枚举
 * @author ShenWenhao
 * @Created by ShenWenhao
 * @Date 2022/5/9 20:49
 */
@Getter
@AllArgsConstructor
public enum DeletedEnum {

    DELETED(0, "已删除"),
    NOT_DELETED(1, "未删除");

    private final int code;

    private final String desc;

    /**
     * 根据 code 获取枚举对象
     * @param code
     * @return
     */
    public static DeletedEnum valueOf(int code){
        for(DeletedEnum deletedEnum: DeletedEnum.values()){
            if(deletedEnum.getCode() == code){
                return deletedEnum;
            }
        }
        return null;
    }
}
